package com.boodaba.todocarts.domain;

public class DbtIdSpecification<T extends DrivenByTitle<?>> {
	private final String mTargetTitle;
	
	public DbtIdSpecification(String title) {
		mTargetTitle = title;
	}
	
	public DbtIdSpecification(T dbtEntity) {
		this(dbtEntity == null ? null : dbtEntity.mTitle);
	}
	
	public Boolean isSatisfiedBy(T entity) {
		return entity != null
				&& (mTargetTitle == null && entity.mTitle == null
					|| mTargetTitle != null && mTargetTitle.equals(entity.mTitle));
	}

}
